package cn.stylefeng.guns.modular.demo.controller;

import cn.stylefeng.guns.modular.demo.entity.FixedAssetsInformation;
import cn.stylefeng.guns.modular.demo.pojo.request.FixedAssetsInformationRequest;
import cn.stylefeng.guns.modular.demo.service.FixedAssetsInformationService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 固定资产信息表控制器
 *
 * @author admin
 * @date 2022/11/19 18:06
 */
@RestController
@ApiResource(name = "固定资产信息表")
public class FixedAssetsInformationController {

    @Resource
    private FixedAssetsInformationService fixedAssetsInformationService;

    /**
     * 添加
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "添加", path = "/fixedAssetsInformation/add")
    public ResponseData<FixedAssetsInformation> add(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        fixedAssetsInformationService.add(fixedAssetsInformationRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "删除", path = "/fixedAssetsInformation/delete")
    public ResponseData<?> delete(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        fixedAssetsInformationService.del(fixedAssetsInformationRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "编辑", path = "/fixedAssetsInformation/edit")
    public ResponseData<?> edit(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        fixedAssetsInformationService.edit(fixedAssetsInformationRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看详情
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "查看详情", path = "/fixedAssetsInformation/detail")
    public ResponseData<FixedAssetsInformation> detail(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        return new SuccessResponseData<>(fixedAssetsInformationService.detail(fixedAssetsInformationRequest));
    }

    /**
     * 获取列表
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "获取列表", path = "/fixedAssetsInformation/list")
    public ResponseData<List<FixedAssetsInformation>> list(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        return new SuccessResponseData<>(fixedAssetsInformationService.findList(fixedAssetsInformationRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "分页查询", path = "/fixedAssetsInformation/page")
    public ResponseData<PageResult<FixedAssetsInformation>> page(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        return new SuccessResponseData<>(fixedAssetsInformationService.findPage(fixedAssetsInformationRequest));
    }

    /**
     * 归还/借出
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "借出", path = "/fixedAssetsInformation/lend")
    public ResponseData<?> lend(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        fixedAssetsInformationService.lend(fixedAssetsInformationRequest);
        return new SuccessResponseData<>();
    }
    /**
     * 归还/借出
     *
     * @author admin
     * @date 2022/11/19 18:06
     */
    @PostResource(name = "归还", path = "/fixedAssetsInformation/back")
    public ResponseData<?> back(@RequestBody FixedAssetsInformationRequest fixedAssetsInformationRequest) {
        fixedAssetsInformationService.back(fixedAssetsInformationRequest);
        return new SuccessResponseData<>();
    }
}
